/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jrill;

/**
 * Straight forward implementation of {@link Recipient}
 * @author Kazuto Waga<kzwaga at gmail.com>
 */
public class SimpleRecipient implements Recipient {

    private Long id;
    
    private Participant participant;
    /** Default Type is To */
    private Type type = Type.To;
    
    private Long version;
    
    /**
     * Default Constructor
     */
    public SimpleRecipient() {

    }
    
    /**
     * Constructor
     * @param id Recipient ID
     * @param type Recipirnt Type
     * @param participant Participant as Recipient
     */
    public SimpleRecipient(Long id, Type type, Participant participant) {
        this(id, null, type, participant);
    }

    /**
     * Full constructor
     * @param id Recipient ID
     * @param version Recipient version
     * @param type Recipirnt Type
     * @param participant Participant as Recipient
     */
    public SimpleRecipient(Long id, Long version, Type type, Participant participant) {
        this.id = id;
        this.version = version;
        this.type = type;
        this.participant = participant;
    }

    /**
     * {@inheritDoc }
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * {@inheritDoc }
     * @return the participant
     */
    public Participant getParticipant() {
        return participant;
    }

    /**
     * @param participant the participant to set
     */
    public void setParticipant(Participant participant) {
        this.participant = participant;
    }

    /**
     * @return the type
     */
    public Type getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(Type type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final SimpleRecipient other = (SimpleRecipient) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 29 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 29 * hash + (this.participant != null ? this.participant.hashCode() : 0);
        hash = 29 * hash + (this.type != null ? this.type.hashCode() : 0);
        return hash;
    }

    /**
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * @param version the version to set
     */
    public void setVersion(Long version) {
        this.version = version;
    }

}
